#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

static FILE *fp = NULL;
static char file_name[1024] = {0x00};
static uint32_t file_length = 0;


int main(int argc, char *argv[])
{
    // printf("Hello World!\r\n");

    if (argc < 2) {
        system("pause");
        return 1;
    }

	strncpy(file_name, (char *)argv[1], sizeof(file_name));
    if ((fp = fopen(file_name, "rb")) == NULL) {
        printf(" ERROR: open file fail!!!\r\n");
        system("pause");
        return 1;
    }

    fseek(fp, 0L, SEEK_END);
    file_length = ftell(fp);
    printf("file_length = %d-byte\r\n", file_length);
    fseek(fp, 0L, SEEK_SET);


    uint8_t data = 0x00;
    for (uint32_t i = 0; i < file_length; i++)
    {
        fread(&data, 1, 1, fp);
        if (data != 0xFF)
        {
            printf("position = 0x%08X, data = 0x%02X\r\n", i, data);
        }
    }


    fclose(fp);

    system("pause");
    return 0;
}
